
var PluploadCustom = function () {
    return {
        initDrag: function (el) {
            // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
            // it doesn't need to have a start or end
            var eventObject = {
                title: $.trim(el.text()) // use the element's text as the event title
            };
            // store the Event Object in the DOM element so we can get to it later
            el.data('eventObject', eventObject);
            // make the event draggable using jQuery UI
            el.draggable({
                zIndex: 999,
                revert: true, // will cause the event to go back to its
                revertDuration: 0 //  original position after the drag
            });
        },
        sortable: function (el) {
            if (!jQuery().sortable) {
                return;
            }
            jQuery(el).sortable({
                items: ".plupload_file",
                opacity: 0.8,
                handle: '.plupload_file_thumb',
                coneHelperSize: true,
                placeholder: 'plupload_file-sortable-placeholder',
                forcePlaceholderSize: true,
                tolerance: "pointer",
                helper: "clone",
                cursor: "move",
                delay: 50,
                cancel: "img,textarea", // cancel dragging if portlet is in fullscreen mode
                revert: 150, // animation in milliseconds
                update: function (b, c) {
                    console.log(b);
                    console.log(c);
                    if (c.item.prev().hasClass("portlet-sortable-empty")) {
                        c.item.prev().before(c.item);
                    }
                }
            });
        },
        tplUploadItem: function (uploader, file) {
            var settings = uploader.settings;
            var path = file.path;
            var filesize = file.size;

            var activeInputId = settings.id + '-' + file.id;
            var activeInputName = settings.input_name + '[' + file.id + ']';

            if (window.plupload) {
                filesize = window.plupload.formatSize(filesize);
            }
            var temp = '<li class="plupload_file plupload_file_loading" id="' + file.id + '">';

            if (settings.multi_selection === true) {
                temp += '<input id="' + activeInputId + '-path' + '" name="' + activeInputName + '[path]' + '" value="' + path + '" type="hidden" class="plupload_file_input">';
            }

            if (path === undefined) {
                path = settings.error_image_url;
            }

            temp += '<div class="plupload_file_thumb"><img src="' + path + '" draggable="0" /></div>';
            temp += '<div class="plupload_file_action"><i class="ionicons ion-trash-a"></i></div>';

            temp += '<div class="plupload_file_status">' +
                    '<div class="plupload_file_progress">' +
                    '<div class="plupload_file_percent">?</div>' +
                    '<div class="progress">' +
                    '<span class="progress-bar"></span>' +
                    '</div>' +
                    '<span class="plupload_file_mark">准备上传</span>' +
                    '</div>' +
                    '</div>';

            temp += '<div class="plupload_file_description"><textarea id="' + activeInputId + '-description" name="' + activeInputName + '[description]" placeholder="可以为图片添加描述内容"></textarea></div>';

            //temp += '<div class="plupload_file_size">' + filesize + '</div>';

            return temp += '</li>';
        }
    };
}();


document.body.ondrop = function (event) {
    event.preventDefault();
    event.stopPropagation();
}